#!/usr/bin/python
# -*- coding: utf-8 -*-

__all__ = [u"UiInterface"]

from _pylot.core.utils import check_type

from _pylot.interfaces.handler import (HandlerInterface, DEFAULT_HANDLER)
from _pylot.interfaces.iohandler import IOHandlerInterface
from _pylot.interfaces.processhandler import ProcessHandlerInterface

class UiInterface (object):

  def __init__(self, handler=None):
    self._children = {}
    if handler is None :
      handler = DEFAULT_HANDLER
    self._handler = handler

  def init(self, io_handler=None, process_handler=None):
    self.handler.init(io_handler, process_handler)

  def _gethandler(self):
    u"""The handler to which are delegated all works.
    :returns: the handler.
    :rtype: :class:`~_pylot.interfaces.HandlerInterface`
    """
    return self._handler

  def _sethandler(self, handler=None):
    u"""The handler to which are delegated all works.
    :type handler: :class:`~_pylot.interfaces.HandlerInterface`
    """
    check_type(u'handler', handler, HandlerInterface)
    self._handler = handler #the handler to which are delegated all works.

  u"""the handler to which are delegated all works."""

  handler = property(_gethandler, _sethandler)
